﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace kehuguanli.Common
{
    public class MessageBox : System.Web.UI.Page
    {
        /// <summary>
        /// 普通的弹出窗体
        /// </summary>
        /// <param name="p"></param>
        /// <param name="msg"></param>
        public static void Show(Page p, string msg, string strKey)
        {
            p.ClientScript.RegisterStartupScript(p.GetType(), strKey, "alert(\"" + msg + "\");", true);
        }

        /// <summary>
        /// 弹出信息，后在本页打开新页面
        /// </summary>
        /// <param name="p"></param>
        /// <param name="msg">警告信息</param>
        /// <param name="url">网址</param>
        public static void Show(Page p, string msg, string url, string strKey)
        {
            p.ClientScript.RegisterStartupScript(p.GetType(), strKey, "alert(\"" + msg + "\");location.href=\"" + url + "\";", true);
        }

        /// <summary>
        /// 弹出信息，后在指定位置打开新页面
        /// </summary>
        /// <param name="p"></param>
        /// <param name="msg">警告信息</param>
        /// <param name="tag">前缀</param>
        /// <param name="url">网址</param>
        public static void Show(Page p, string msg, string tag, string url, string strKey)
        {
            p.ClientScript.RegisterStartupScript(p.GetType(), strKey, "alert(\"" + msg + "\");" + tag + ".location.href=\"" + url + "\";", true);
        }
        /// <summary>
        /// location跳转到指定页面
        /// </summary>
        /// <param name="p"></param>
        /// <param name="url"></param>
        public static void RefreshPage(Page p, string url, string strKey)
        {
            p.ClientScript.RegisterStartupScript(p.GetType(), strKey, "location.href=\"" + url + "\";", true);
        }

        /// <summary>
        ///在指定位置 location跳转到指定页面
        /// </summary>
        /// <param name="p"></param>
        /// <param name="tag">页面前缀</param>
        /// <param name="url">要刷新页面地址</param>
        public static void RefreshPage(Page p, string tag, string url, string strKey)
        {
            p.ClientScript.RegisterStartupScript(p.GetType(), strKey, tag + ".location.href=\"" + url + "\";", true);
        }
        /// <summary>
        /// 刷新本页面
        /// </summary>
        /// <param name="p"></param>
        /// <param name="tag"></param>
        public static void ReloadPage(Page p, string tag, string strKey)
        {
            p.ClientScript.RegisterStartupScript(p.GetType(), strKey, tag + ".location.reload();", true);
        }
        /// <summary>
        /// 自定义弹出信息 可以自己写弹出模式
        /// </summary>
        /// <param name="p"></param>
        /// <param name="tag"></param>
        public static void myScriptMes(Page p, string strNote, string strKey)
        {
            p.ClientScript.RegisterStartupScript(p.GetType(), strKey, strNote, true);
        }
    }
}
